import getCurrentComponent from './get-current-component'

export default function (selector: string, vm: any, isAll = false) {
  return new Promise((resolve) => {
    const selectorQuery = uni.createSelectorQuery()

    selectorQuery
      .in(vm ? vm : getCurrentComponent())
      [isAll ? 'selectAll' : 'select'](selector)
      .boundingClientRect((data) => {
        resolve(data)
      })
      .exec()
  })
}
